home *** CD-ROM | disk | FTP | other *** search
/ Giga Games 1 / Giga Games.iso / net / hack / 3_1 / win / x11 / window.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-21  |  5.1 KB  |  159 lines

  1. /*    SCCS Id: @(#)Window.c    3.1    92/3/7
  2. /* Copyright (c) Dean Luick, 1992                  */
  3. /* NetHack may be freely redistributed.  See license for details. */
  4.  
  5. /*
  6.  * Data structures and support routines for the Window widget.  This is a
  7.  * drawing canvas with 16 colors and one font.
  8.  */
  9. #include <X11/IntrinsicP.h>
  10. #include <X11/StringDefs.h>
  11. #include "WindowP.h"
  12.  
  13. static XtResource resources[] = {
  14. #define offset(field) XtOffset(WindowWidget, window.field)
  15.     /* {name, class, type, size, offset, default_type, default_addr}, */
  16.     { XtNrows, XtCRows, XtRDimension, sizeof(Dimension),
  17.       offset(rows), XtRImmediate, (XtPointer) 21},
  18.     { XtNcolumns, XtCColumns, XtRDimension, sizeof(Dimension),
  19.       offset(columns), XtRImmediate, (XtPointer) 80},
  20.     { XtNforeground, XtCForeground, XtRPixel, sizeof(Pixel),
  21.       offset(foreground), XtRString, XtDefaultForeground },
  22.  
  23.     { XtNblack, XtCColor, XtRPixel, sizeof(Pixel),
  24.       offset(black), XtRString, "black"},
  25.     { XtNred, XtCColor, XtRPixel, sizeof(Pixel),
  26.       offset(red), XtRString, "red" },
  27.     { XtNgreen, XtCColor, XtRPixel, sizeof(Pixel),
  28.       offset(green), XtRString, "pale green" },
  29.     { XtNbrown, XtCColor, XtRPixel, sizeof(Pixel),
  30.       offset(brown), XtRString, "brown" },
  31.     { XtNblue, XtCColor, XtRPixel, sizeof(Pixel),
  32.       offset(blue), XtRString, "blue" },
  33.     { XtNmagenta, XtCColor, XtRPixel, sizeof(Pixel),
  34.       offset(magenta), XtRString, "magenta" },
  35.     { XtNcyan, XtCColor, XtRPixel, sizeof(Pixel),
  36.       offset(cyan), XtRString, "light cyan" },
  37.     { XtNgray, XtCColor, XtRPixel, sizeof(Pixel),
  38.       offset(gray), XtRString, "gray" },
  39.     { XtNorange, XtCColor, XtRPixel, sizeof(Pixel),
  40.       offset(orange), XtRString, "orange" },
  41.     { XtNbright_green, XtCColor, XtRPixel, sizeof(Pixel),
  42.       offset(bright_green), XtRString, "green" },
  43.     { XtNyellow, XtCColor, XtRPixel, sizeof(Pixel),
  44.       offset(yellow), XtRString, "yellow" },
  45.     { XtNbright_blue, XtCColor, XtRPixel, sizeof(Pixel),
  46.       offset(bright_blue), XtRString, "royal blue" },
  47.     { XtNbright_magenta, XtCColor, XtRPixel, sizeof(Pixel),
  48.       offset(bright_magenta), XtRString, "violet" },
  49.     { XtNbright_cyan, XtCColor, XtRPixel, sizeof(Pixel),
  50.       offset(bright_cyan), XtRString, "cyan" },
  51.     { XtNwhite, XtCColor, XtRPixel, sizeof(Pixel),
  52.       offset(white), XtRString, "white" },
  53.  
  54.     { XtNfont, XtCFont, XtRFontStruct, sizeof(XFontStruct *),
  55.       offset(font), XtRString, XtDefaultFont },
  56.     { XtNexposeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
  57.       offset(expose_callback), XtRCallback, NULL },
  58.     { XtNcallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
  59.       offset(input_callback), XtRCallback, NULL },
  60.     { XtNresizeCallback, XtCCallback, XtRCallback, sizeof(XtCallbackList),
  61.       offset(resize_callback), XtRCallback, NULL },
  62. #undef offset
  63. };
  64.  
  65. /* ARGSUSED */
  66. static void InputAction(w, event, params, num_params)
  67.     Widget   w;
  68.     XEvent   *event;
  69.     String   *params;        /* unused */
  70.     Cardinal *num_params;    /* unused */
  71. {
  72.     XtCallCallbacks(w, XtNcallback, (caddr_t) event);
  73. }
  74.  
  75. /* ARGSUSED */
  76. static void no_op(w, event, params, num_params)
  77.     Widget   w;            /* unused */
  78.     XEvent   *event;        /* unused */
  79.     String   *params;        /* unused */
  80.     Cardinal *num_params;    /* unused */
  81. {
  82. }
  83.  
  84. static XtActionsRec actions[] =
  85. {
  86.     {"input",    InputAction},
  87.     {"no-op",    no_op},
  88. };
  89.  
  90. static char translations[] =
  91. "<Key>:        input()    \n\
  92.  <BtnDown>:    input() \
  93. ";
  94.  
  95. /* ARGSUSED */
  96. static void Redisplay(w, event, region)
  97.     Widget w;
  98.     XEvent *event;    /* unused */
  99.     Region *region;
  100. {
  101.     XtCallCallbacks(w, XtNexposeCallback, (caddr_t) region);
  102. }
  103.  
  104. /* ARGSUSED */
  105. static void Resize(w)
  106.     Widget w;
  107. {
  108.     XtCallCallbacks(w, XtNresizeCallback, (caddr_t) NULL);
  109. }
  110.  
  111.  
  112. WindowClassRec windowClassRec = {
  113.   { /* core fields */
  114.     /* superclass        */    (WidgetClass) &widgetClassRec,
  115.     /* class_name        */    "Window",
  116.     /* widget_size        */    sizeof(WindowRec),
  117.     /* class_initialize        */    NULL,
  118.     /* class_part_initialize    */    NULL,
  119.     /* class_inited        */    FALSE,
  120.     /* initialize        */    NULL,
  121.     /* initialize_hook        */    NULL,
  122.     /* realize            */    XtInheritRealize,
  123.     /* actions            */    actions,
  124.     /* num_actions        */    XtNumber(actions),
  125.     /* resources        */    resources,
  126.     /* num_resources        */    XtNumber(resources),
  127.     /* xrm_class        */    NULLQUARK,
  128.     /* compress_motion        */    TRUE,
  129.     /* compress_exposure    */    TRUE,
  130.     /* compress_enterleave    */    TRUE,
  131.     /* visible_interest        */    FALSE,
  132.     /* destroy            */    NULL,
  133.     /* resize            */    Resize,
  134.     /* expose            */    Redisplay,
  135.     /* set_values        */    NULL,
  136.     /* set_values_hook        */    NULL,
  137.     /* set_values_almost    */    XtInheritSetValuesAlmost,
  138.     /* get_values_hook        */    NULL,
  139.     /* accept_focus        */    NULL,
  140.     /* version            */    XtVersion,
  141.     /* callback_private        */    NULL,
  142.     /* tm_table            */    translations,
  143.     /* query_geometry        */    XtInheritQueryGeometry,
  144.     /* display_accelerator    */    XtInheritDisplayAccelerator,
  145.     /* extension        */    NULL
  146.   },
  147.   { /* window fields */
  148.     /* empty            */    0
  149.   }
  150. };
  151.  
  152. WidgetClass windowWidgetClass = (WidgetClass)&windowClassRec;
  153.  
  154. Font
  155. WindowFont(w) Widget w; { return ((WindowWidget)w)->window.font->fid; }
  156.  
  157. XFontStruct *
  158. WindowFontStruct(w) Widget w; { return ((WindowWidget)w)->window.font; }
  159.